\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 C++ gdb bug workaround\
\
Q: When I tried to trace my C++ program with gdb, gdb just crashes with a Bus Error message. Why is this happening?\
\
A: There is a problem with using gdb and C++, when you forward declare a class, then try to use the class as a static member of another class. The following code snippet shows the problem, and how to work around it:\
\
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f1\b\fs24\fc0 class A;
\b0 \
\
class B\
\{\
\b static A *a;
\b0 \
public:\
B()\{\};\
\};\
\
\
main()\
\{\
int i;\
i=2;\
\}\
\
class A\{\
int x;\
\};\
\
\f0\fs28 Note that class B has a static class variable (or in the C++ jargon, a static class member) , but no instance variable (or in the C++ jargon, no member). The workaround is to add a dummy instance variable to the class definition:\